package servlet;

import bean.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "VolSolveServlet", value = "/volunteer/VolSolveServlet")
public class VolSolveServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        HttpSession session = request.getSession();
        response.setContentType("text/html;charset=utf-8");
        String id=request.getParameter("id");
        String name=request.getParameter("name");
        HelpBean serviceBean=new HelpBean();
        serviceBean.link();
        serviceBean.loadHelp();
        Help app=null;
        for(Help a:serviceBean.getHelpArrayList()){
            if(id.equals(a.getId())&&name.equals(a.getName())){
                app=a;
            }
        }
        app.setSolve("已处理");
        serviceBean.updateHelp(app);
        response.sendRedirect("vol_sovle.jsp");
    }
}